package com.jjh.util;

import java.io.*;

/**
 * 打印一些图案
 */
public class ViewUtils {

    private static final String LOGO_PATH = "E:\\EeleMa\\src\\main\\resources\\logo.txt";
    private static final String WINTER_BANNER = "src/main/resources/banner.txt";
    /**
     * 打印付款成功的图案
     */
    public static void printOrderSuccess(){
        System.out.println("-----------------------");
        System.out.println("----            %------");
        System.out.println("----   %       %-------");
        System.out.println("----     %    %  ------");
        System.out.println("---        % %   ------");
        System.out.println("-----------------------");
    }


    public static void printLogo() {

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(LOGO_PATH)));
            String msg = null;
            while ((msg = reader.readLine()) != null) {
                System.out.println(msg);
            }


        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
        /**
         * 打印winterLOGO
         */
        public static void printWinterLogo(){

            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(WINTER_BANNER)));
                String msg = null;
                while ((msg=reader.readLine())!=null){
                    System.out.println(msg);
                }


            } catch (IOException e) {
                throw new RuntimeException(e);
            }


    }

    /**
     * 清屏
     */
    public static void cls(){
        try {
            new ProcessBuilder("cmd", "/c", "cls")
                    // 将 ProcessBuilder 对象的输出管道和 Java 的进程进行关联，这个函数的返回值也是一个
                    // ProcessBuilder
                    .inheritIO()
                    // 开始执行 ProcessBuilder 中的命令
                    .start()
                    // 等待 ProcessBuilder 中的清屏命令执行完毕
                    // 如果不等待则会出现清屏代码后面的输出被清掉的情况
                    .waitFor(); // 清屏命令
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }




}
